package com.atguigu.day06;

public class Test01 {
    public static void main(String[] args) {
        Count c1 = new Count();
        System.out.println("sum不传参 : " + c1.sum());
        System.out.println("sum(1, 2, 3, 4, 5):" + c1.sum(1, 2, 3, 4, 5));
        System.out.println("max(6, 1, 4, 5, 6, 7, 2, 3, 8, 6, 2):" + c1.max(6, 1, 4, 5, 6, 7, 2, 3, 8, 6, 2));
        System.out.println("concat(Hell, oWor, ld):" + c1.concat("Hell", "oWor", "ld"));
        System.out.println("isEven(1, 2, 3, 4, 5):" + c1.isEven(1, 2, 3, 4, 5));
        System.out.println("isEven(2, 4, 6, 8, 10):" + c1.isEven(2, 4, 6, 8, 10));
    }
}

class Count {
    public long sum(int... nums) {
        int sum = 0;
        if (nums == null) {
            return 0;
        }
        for (int i = 0; i < nums.length; i++)
            sum += nums[i];
        return sum;
    }

    public int max(int a, int... other) {
        int max = other[0];
        for (int i = 0; i < other.length - 1; i++) {
            max = max > other[i + 1] ? max : other[i + 1];
        }
        return max;
    }

    //1,4,5,6,7,2,3,8
//
    public String concat(String... strings) {
        String s = "";
        for (int i = 0; i < strings.length; i++) {
            s += strings[i];
        }
        return s;
    }

    public boolean isEven(int... nums) {
        boolean isEven = true;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] % 2 != 0)
                isEven = false;
        }
        return isEven;
    }
}

